#define _CRT_SECURE_NO_WARNINGS
#include"stdio.h"
int main() {
	int arr1[100] = { 0 };
	int arr2[100] = { 0 };
	int n=0, m=0;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr1[i]);
	}
	for (int j = 0; j < m; j++) {
		scanf("%d", &arr2[j]);
	}
	int i = 0, j = 0;
	while (i < n && j < m) {
		if (arr1[i] < arr2[j]) {
			printf("%d ", arr1[i]);
			i++;
		}
		else {
			printf("%d ", arr2[j]);
			j++;
		}
	}
	while (i<n) {
		printf("%d ", arr1[i]);
		i++;
	}
	while (j < m) {
		printf("%d ", arr2[j]);
		j++;
	}
	return 0;
}